<template>
	<view>
		<view class="" v-if="public.isnews==0">
			<oldme :user='user'></oldme>
		</view>
		<view class="" v-else>
			<newme ref='newme' :user='user'></newme>
		</view>
	</view>
</template>

<script>
	import {
		userInfo
	} from "@/api/public.js"
	export default {
		data() {
			return {
				user: uni.getStorageSync('user'),
				public: uni.getStorageSync("public"),
				token: uni.getStorageSync("userinfo").token
			};
		},

		onLoad() {
			let token = uni.getStorageSync("userinfo").token
			if (token) {
				this.user = uni.getStorageSync('user')
				this.token = uni.getStorageSync("userinfo")
				this.getUser()
			} else {
				this.user = null
			}
		},
		onShow() {
			let token = uni.getStorageSync("userinfo").token
			if (token) {
				this.user = uni.getStorageSync('user')
				this.token = uni.getStorageSync("userinfo")
				this.getUser()
			} else {
				this.$refs.newme.percentage = 0
				this.$refs.newme.token = null
				this.user = null
			}
		},
		methods: {
			async getUser() {
				let user = await userInfo()
				if (user.code == 1) {
					uni.setStorageSync('user', user.data)
					this.$refs.newme.getUser()
				}
			},
			contact(e) {},


		}
	}
</script>
<style>

</style>